package com.heima.admin.controller.v1;


import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**对敏感词进行操作
 *
 */
@Api(value = "敏感词管理API",tags = "敏感词管理API")
@RestController
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController {

    //注入
    @Autowired
    private AdSensitiveService adSensitiveService;

    @DeleteMapping("/del/{id}")
    @ApiOperation("敏感词删除")
    public ResponseResult deleteById(@PathVariable("id") Integer id){
      return   adSensitiveService.deleteById(id);
    }

    @PostMapping("list")
    @ApiOperation("敏感词分页查询")
    public ResponseResult querySensitive(@RequestBody SensitiveDTO dto){
        return   adSensitiveService.querySensitiveList(dto);
    }

    @PostMapping("save")
    @ApiOperation("保存敏感词信息")
    public ResponseResult insert(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.insertSensitive(adSensitive);
    }

    @PostMapping("update")
    @ApiOperation("敏感词修改")
    public ResponseResult update(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.updateSensitive(adSensitive);
    }

    @ApiOperation(value = "查询敏感词内容list")
    @PostMapping("/sensitives")
    public ResponseResult sensitives() {
        return adSensitiveService.selectAllSensitives();
    }


}
